package com.hongfasoft.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import uniesb.sdk.util.JSON;

import com.hongfasoft.util.SignUtil;
import com.hongfasoft.util.WeixinUtil;

/**
 * @name
 * @desc
 * @group
 * @jdk
 * @os
 * @author 王涛
 * @date 2015年5月21日
 */
public class GetSignMap extends HttpServlet
{
	private static String url = "http://wx.zjldl.cn";
	private static final long serialVersionUID = 1347419854335465426L;

	public void doGet(HttpServletRequest req, HttpServletResponse resp)
	{
		doPost(req, resp);
	}

	public void doPost(HttpServletRequest req, HttpServletResponse resp)
	{
		String apitype = req.getParameter("jsapi_type");
		Map<String, String> signMap = SignUtil.sign(apitype, url);
		signMap.put("appId", WeixinUtil.getAppid());
		try
		{
			PrintWriter pr = resp.getWriter();
			pr.write(JSON.toJSON(signMap));
			pr.flush();
			pr.close();
		} catch (IOException e)
		{
			e.printStackTrace();
		}
	}
}
